package com.game.model.role;

import com.game.config.Coefficient;
import com.game.model.BaseProperty;
import com.game.model.SpecialProperty;
import com.game.model.task.Task;

import java.util.Map;

/**
 * @Description:
 **/
public class NPC extends Role {
    private String speakText;//谈话内容
    private Map<Integer, Task> taskMap;//NPC任务表

    public NPC() {
    }

    public NPC(int id, String name, int level, BaseProperty baseProperty, SpecialProperty specialProperty, String description, String speakText, Map<Integer, Task> taskMap) {
        super(id, name, level, baseProperty, specialProperty, description);
        this.speakText = speakText;
        this.taskMap = taskMap;
    }


    public String getSpeakText() {
        return speakText;
    }

    public void setSpeakText(String speakText) {
        this.speakText = speakText;
    }


    public void speakE() {

    }

    //交谈
    public void speak() {
        if (speakText==null){
            System.out.println(super.getName() + "：");
            System.out.println("我不想说话");
            return;
        }
        String [] text = speakText.split("");
        System.out.println("【"+super.getName() + "】：");
        for (int i = 0; i < text.length; i++) {
            System.out.print(text[i]);
            if (i >= 30 && i % 30 == 0) {
                System.out.println();
            }
            try {
                Thread.sleep(Coefficient.SPEAKTIME);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println();
    }


    public Map<Integer, Task> getTaskMap() {
        return taskMap;
    }

    public void setTaskMap(Map<Integer, Task> taskMap) {
        this.taskMap = taskMap;
    }
}
